CC          = @CC@
AR          = @AR@
RANLIB      = @RANLIB@
LIBNAME     = @LIBNAME@
srcdir      = @srcdir@
CC_SHL      = @CC_SHL@
SHLIBNAME   = @SHLIBNAME@

#DEFS            = @DEFS@ -I. -I${srcdir}
CPPFLAGS        = @CPPFLAGS@
INCLUDES = -I@MPI_INCLUDE_DIR@ -I${srcdir}/../include -I../include \
	-I../../include -I${srcdir}/../../../../../src/include \
	-I../../../../../src/include
#CFLAGS      = @CPPFLAGS@ @CFLAGS@ $(INCLUDES) 
CFLAGS          = @CFLAGS@
top_builddir    = @master_topbuild_dir@
LIBTOOL         = @LIBTOOL@
C_COMPILE       = $(CC) $(DEFS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS)
C_COMPILE_SHL   = $(CC_SHL) $(DEFS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS)
#C_COMPILE_SHL = $(CC_SHL) 

@VPATH@

AD_OBJECTS = ad_close.o ad_init.o ad_end.o ad_open.o flatten.o \
      malloc.o ad_read_coll.o eof_offset.o \
      ad_write_coll.o lock.o ad_read_str.o ad_write_str.o iscontig.o \
      get_fp_posn.o ad_seek.o ad_delete.o ad_flush.o ad_hints.o error.o \
      ad_fstype.o ad_get_sh_fp.o ad_set_sh_fp.o shfp_fname.o byte_offset.o \
      status_setb.o ad_aggregate.o cb_config_list.o \
      ad_read_str_naive.o ad_set_view.o ad_iopen.o \
      ad_write_str_naive.o ad_resize.o ad_read.o ad_write.o ad_iread.o \
      ad_iwrite.o ad_done.o ad_wait.o adi_close.o ad_prealloc.o ad_fcntl.o \
      ad_iread_fake.o ad_iwrite_fake.o ad_done_fake.o ad_wait_fake.o \
      ad_subarray.o ad_darray.o strfns.o greq_fns.o system_hints.o \
      ad_write_nolock.o \
      ad_coll_exch_new.o ad_coll_build_req_new.o ad_io_coll.o \
      ad_aggregate_new.o heap-sort.o \
      ad_opencoll.o ad_opencoll_scalable.o ad_opencoll_failsafe.o ad_features.o

all: $(LIBNAME)
	@if [ "@ENABLE_SHLIB@" != "none" ] ; then \
	    $(MAKE) $(SHLIBNAME).la ;\
	fi

.SUFFIXES: $(SUFFIXES) .p .lo

#	$(CC) $(CFLAGS) $(INC) -c $<
.c.o:
	@if [ "x$(VERBOSE)" != "x1" ] ; then \
	  echo "  CC              $<" ; \
	else \
	  echo $(C_COMPILE) -c $< ; \
	fi
	@$(C_COMPILE) -c $<
#	$(C_COMPILE_SHL) $(CFLAGS) -c $< -o _s$*.o
#	@mv -f _s$*.o $*.lo
.c.lo:
	@if [ "x$(VERBOSE)" != "x1" ] ; then \
	  echo "  CC              $<" ; \
	else \
	  echo $(C_COMPILE_SHL) -c $< -o _s$*.o ; \
	  echo mv -f _s$*.o $*.lo ; \
	fi
	@$(C_COMPILE_SHL) -c $< -o _s$*.o
	@mv -f _s$*.o $*.lo

$(LIBNAME): $(AD_OBJECTS)
	$(AR) $(LIBNAME) $(AD_OBJECTS)
	$(RANLIB) $(LIBNAME) 

AD_LOOBJECTS = $(AD_OBJECTS:.o=.lo)

$(SHLIBNAME).la: $(AD_LOOBJECTS)
	$(AR) $(SHLIBNAME).la $(AD_LOOBJECTS)

coverage:
	-@for file in  ${AD_OBJECTS:.o=.c} ; do \
		gcov -b -f $$file ; done

clean:
	@rm -f *.o *.lo *.gcno *.gcda *.bb *.bbg
	@rm -f ${srcdir}/*.gcno ${srcdir}/*.gcda 
	@rm -f ${srcdir}/*.bb ${srcdir}/*.bbg

tags: TAGS
SOURCES = ${AD_OBJECTS:.o=.c}
HEADERS = 
TAGS:${HEADERS} ${SOURCES}
	here=`cd ../../../../.. && pwd` ; cd ${srcdir} && etags -o $$here/TAGS --append ${HEADERS} ${SOURCES}
